package com.test.service.impl;

import com.test.dao.ITemperaturePanelCurrentDao;
import com.test.model.TemperaturePanelCurrentData;
import com.test.service.ITemperaturePanelCurrentService;
import com.test.service.ITemperaturePanelHistoricalService;
import com.test.utils.TemperaturePanelCurrentGenerate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by ZZF on 2017/7/7.
 */
@Service
public class TemperaturePanelCurrentServiceImpl implements ITemperaturePanelCurrentService {

    @Autowired
    ITemperaturePanelCurrentDao temperaturePanelCurrentDao;

    @Autowired
    ITemperaturePanelHistoricalService temperaturePanelHistoricalService;

    @Override
    public void updatePanel() {
        List<TemperaturePanelCurrentData> all = temperaturePanelCurrentDao.getAll(TemperaturePanelCurrentData.class);
        for (TemperaturePanelCurrentData temperaturePanelCurrentData : all) {

            //模拟生成温度面板的数据
            TemperaturePanelCurrentData generate = TemperaturePanelCurrentGenerate.Generate(temperaturePanelCurrentData);
            //修改温度面板的数据
            temperaturePanelCurrentDao.update(generate);

            //温控模板的历史记录
            temperaturePanelHistoricalService.addHistorical(generate);
        }


    }
}
